#include <boost/thread.hpp>
#include <iostream>

void wait(int seconds)
{
	boost::this_thread::sleep(boost::posix_time::seconds(seconds) );
}
boost::mutex mutex;
void thread_func()
{
	std::cout << "Thread ID: " << boost::this_thread::get_id() << std::endl;
	for (int i=0; i<5; ++i){
		wait(1);
		boost::lock_guard<boost::mutex> lock(mutex);
		std::cout << i << std::endl;
	}
}

int main()
{
	std::cout << "Thread ID: " << boost::this_thread::get_id() << std::endl;
	std::cout << "#Physical Thread: " << boost::thread::hardware_concurrency() 
		<< std::endl;

	boost::thread t1(thread_func);
	boost::thread t2(thread_func);
	t1.join();
	t2.join();
}